package com.atguigu.admin.service.impl;

import com.atguigu.admin.mapper.SysUserRoleMapper;
import com.atguigu.admin.model.entity.SysUserRole;
import com.atguigu.admin.service.SysUserRoleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 用户角色 服务实现类
 * </p>
 *
 * @author atguigu
 * @since 2022-10-28
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {

    @Override
    public List<SysUserRole> getSysUserRoles(Long userId) {
        QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        //获取用户已分配的角色
        return this.list(queryWrapper);
    }
}
